Remove mocks from AI test files and implement full-stack testing#214
Open
devin-ai-integration[bot] wants to merge 5 commits intomainfrom
Open
Remove mocks from AI test files and implement full-stack testing#214devin-ai-integration[bot] wants to merge 5 commits intomainfrom
devin-ai-integration[bot] wants to merge 5 commits intomainfrom
Conversation
- Remove vi.mock() calls from AI.test.tsx, ai.test.ts, and language-models tests - Remove mock implementations in beforeEach blocks - Add setupAITestEnvironment() function for real AI gateway configuration - Implement caching mechanism for AI responses in tests - Update test expectations to handle real AI responses instead of mocked data - Configure 30-second timeouts for real API calls - Maintain existing test patterns while enabling full-stack testing This enables tests to use real AI calls through the AI gateway with caching, providing more accurate testing of the actual system behavior. Co-Authored-By: Nathan <nateclev@gmail.com>
- Rename providerModel function to avoid conflicts - Update build.js to properly compile provider module - Fix export structure to prevent missing module errors Co-Authored-By: Nathan <nateclev@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: Nathan <nateclev@gmail.com>
…uild - Update build.js to compile provider.ts to dist/src/provider.js - Add export for provider.js in index.ts to resolve module resolution issues - Fixes 'Cannot find module' error in ai-props tests Co-Authored-By: Nathan <nateclev@gmail.com>
- Add provider.js compilation to dist/provider.js for cached .pnpm compatibility - Keep existing dist/src/provider.js for updated index.js structure - Resolves module resolution error in CI environment Co-Authored-By: Nathan <nateclev@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove mocks from AI test files and implement full-stack testing
Summary
This PR removes mocks from AI test files (
AI.test.tsx,ai.test.ts, andlanguage-modelstests) and implements full-stack testing using real AI gateway calls with caching. The changes enable more accurate testing of actual system behavior while maintaining test performance through AI gateway caching.Key changes:
vi.mock()calls forai-functions,ai-providers, and@ai-sdk/openaisetupAITestEnvironment()function for AI gateway configurationReview & Testing Checklist for Human
AI_GATEWAY_URLandAI_GATEWAY_TOKENare properly set for tests to workpnpm test --filter=ai-propsto verify ai-providers imports work correctlyRecommended test plan:
pnpm testto verify all packages passpnpm test --filter=ai-propsmultiple times to check for flakinessDiagram
%%{ init : { "theme" : "default" }}%% graph TB subgraph "AI Props Package" AI_test["packages/ai-props/src/<br/>AI.test.tsx"]:::major-edit test_utils["packages/ai-props/src/<br/>test-utils.ts"]:::minor-edit end subgraph "AI Database Package" ai_db_test["packages/ai-database/src/lib/<br/>__tests__/ai.test.ts"]:::major-edit end subgraph "Language Models Package" lang_test["packages/language-models/<br/>tests/index.test.ts"]:::major-edit end subgraph "AI Providers Package" provider["packages/ai-providers/src/<br/>provider.ts"]:::minor-edit build_js["packages/ai-providers/<br/>build.js"]:::minor-edit end subgraph "AI Functions Package" ai_funcs["packages/ai-functions/<br/>test/utils/setupTests.ts"]:::context end AI_test -->|"uses setupAITestEnvironment"| test_utils AI_test -->|"imports real functions"| ai_funcs ai_db_test -->|"removed @ai-sdk/openai mock"| provider lang_test -->|"removed mocks, added setup"| test_utils provider -->|"build fixes"| build_js subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes